package cate.game.activity.dailylogin.msg;

import cate.common.table.d.GDFunc;
import cate.game.GameBody;
import cate.game.activity.dailylogin.DailyLoginSingle;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBDailyLoginActivity;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "每日登陆-领奖 请求")
public class DailyLoginActivityGetReq implements MsgInput {
    @NoteField("功能ID")
    public int funcId;
    @NoteField(value = "奖励项配置ID")
    public int itemTid;

    @Override
    public MsgConfig conf() {
        return MsgIdBDailyLoginActivity.DAILY_LOGIN_ACTIVITY_GET_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        DailyLoginSingle single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single != null) {
            EcResult<DailyLoginSingle> r = single.receiveReward(itemTid);
            if (r.ok()) {
                r.data.noticeUpdate();
            } else {
                game.notice.message(cc.getRole(), r.message);
            }
        } else {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
        }
    }
}
